<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id="root">
        <counter :count='2' @inc="handleIncrease"></counter>
        <counter :count='3' @inc="handleIncrease"></counter>
        <div>{{total}}</div>
    </div>
    <script>
        var counter = {
            props: [ 'count' ],
            data: function () {
                return {
                    number: this.count
                }
            },
            template: '<div @click="handleClick">{{number}}</div>',
            methods: {
                handleClick: function () {
                    this.number++;
                    this.$emit( 'inc', 1 )
                }
            }
        }
        var vm = new Vue( {
            el: '#root',
            components: {
                counter: counter
            },
            data: {
                total: 5
            },
            methods: {
                handleIncrease: function ( step ) {
                    this.total += step;
                }
            }
        } )
    </script>
</body>

</html>